<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- <meta name="viewport" content="width=800"> -->
    <!-- device 设备 width 宽度『屏幕的设备独立像素』 -->
    <!-- <meta name="viewport" content="width=device-width"> -->
    <!-- initial 初始化  scale 比例 -->
    <!-- <meta name="viewport" content="initial-scale=1"> -->
    <!-- <meta name="viewport" content="width=500, initial-scale=0.5"> -->

    <!-- <meta name="viewport" content="minimum-scale=1"> -->
    <!-- <meta name="viewport" content="maximum-scale=1"> -->
    <!-- <meta name="viewport" content="user-scalable=no"> -->

    <title>Document</title>
    <style>
        *{
            margin:0;
            padding: 0;
        }
        #show{
            width: 400px;
            height: 400px;
            background: #eaf;
        }
    </style>
</head>
<body>
    <div id="show"></div>
    <script>
        // console.log(document.documentElement.clientWidth);
        //定时器 每过50毫秒获取一次 并设置文本
        setInterval(() => {
            show.innerHTML = `
                布局视口: ${document.documentElement.clientWidth}<br/>
                视觉视口: ${window.visualViewport.width}
            `
        }, 50)
    </script>
</body>
</html>